/**
 * 功能描述 卡片
 */

define(function(require, exports, module) {
	var Form = require("form");
	var store = require("store");
	var activeUser = store.get("user");
	var enmu = require("enums");
	var tools = require("tools");
	var Dialog = require("dialog");
	var organization = activeUser.organization.pkOrganization
	var instance = {
		initComponent : function(params, widget) {
			var endForm = new Form({
				parentNode : ".J-endForm",
				model : {
					id : "endForm",
					layout: "3_1",
					saveaction: function() {
						
						widget.handler.endForm.saveactionEvent(widget);
						
                    },
                    cancelaction: function() {
                    	widget.toGrid();
                    },
					items : [{
						name:"personalInfo.idNumber",
						label:"身份证号",
						validate: ["required"],
						events: {
							"blur": function(e){
								var value = e.target.value;
								if(!tools.isIdentityCodeValid(value)){
									Dialog.alert({
			    						content:"您输入的身份证号格式不正确，请重新输入！",
			    						confirm:function(){
			    							endForm.reset();
			    							$(".el-dialog-mask").remove();
			    						}
			    					});
								}else{
									widget.handler.endForm.searchMember(widget,value);
								}
							}
						}
					},{
						name:"personalInfo.name",
						label:"姓名",
						validate: ["required"]
					},{
			            name: "personalInfo.sex",
			            label:"性别",
			            type: "radio",
			            validate: ["required"],
			            defaultValue : "Male",
						list : enmu["com.eling.elcms.basedoc.model.Sex"],
					},{
						name:"personalInfo.mobilePhone",
						label:"联系电话",
						validate: ["required"]
					},{
						id: "birthday",
						name:"personalInfo.birthday",
						label:"出生日期",
						type: "date",
						validate: ["required"]
					},{
						name:"age",
						label:"年龄",
						validate: ["required"],
						readonly: true
					},{
						name:"address",
						label:"省/市/区（县）",
						type: "place",
						validate: ["required"]
					},{
						name:"personalInfo.zipCode",
						label:"邮编",
						validate: ["required"]
					},{
						name:"areaAddress",
						label:"详细地址",
						"break": true,
						validate: ["required"]
					},{
						name:"pkOperator",
						label:"经办人",
						readonly:true,
						defaultValue:activeUser.name
					},{
						name:"operateDate",
						label:"办理日期",
						type:"date",
						mode:"YYYY-MM-DD",
						readonly:true,
						defaultValue:moment()
					},{
						name:"operator",
						type:"hidden",
						defaultValue: activeUser.pkUser
					},{
						name:"remark",
						label:"备注",
						defaultValue : "",
						type:"textarea",
						"break": true,
						exValidate:function(value){		
							if(value.length > 100){
								return "不能超过100个字";
							}else{
								return true;
							}
						}
					},{
						name:"organization",
						type:"hidden",
						defaultValue: organization
					},{
						name:"isMem",
						type:"hidden"
					},{
						name:"pkMember",
						type:"hidden"
					}]
				}
			});
			$(".J-endForm").find(".box-content").before($("<div></div>").addClass("box-header")
					.append($("<div></div>").addClass("title").text("受让人信息")));
			$(".J-form-endForm-date-personalInfo-birthday").append(
                    "<label class='tranditional'><input type='checkbox' id='check' name='checkbox'>农历</label>"
                );
			widget.set("endForm", endForm);
		}
	};
	module.exports = instance;
});
